(0) Obligation:

The Runtime Complexity (innermost) of the given CpxTRS could be proven to be BOUNDS(1, n^2).


The TRS R consists of the following rules:

cond(true, x) → cond(odd(x), p(x))
odd(0) → false
odd(s(0)) → true
odd(s(s(x))) → odd(x)
p(0) → 0
p(s(x)) → x

Rewrite Strategy: INNERMOST

(1) TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID) transformation)

Transformed TRS to weighted TRS

(2) Obligation:

The Runtime Complexity (innermost) of the given CpxWeightedTrs could be proven to be BOUNDS(1, n^2).


The TRS R consists of the following rules:

cond(true, x) → cond(odd(x), p(x)) [1]
odd(0) → false [1]
odd(s(0)) → true [1]
odd(s(s(x))) → odd(x) [1]
p(0) → 0 [1]
p(s(x)) → x [1]

Rewrite Strategy: INNERMOST

(3) TypeInferenceProof (BOTH BOUNDS(ID, ID) transformation)

Infered types.

(4) Obligation:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

cond(true, x) → cond(odd(x), p(x)) [1]
odd(0) → false [1]
odd(s(0)) → true [1]
odd(s(s(x))) → odd(x) [1]
p(0) → 0 [1]
p(s(x)) → x [1]

The TRS has the following type information:
cond :: true:false → 0:s → cond
true :: true:false
odd :: 0:s → true:false
p :: 0:s → 0:s
0 :: 0:s
false :: true:false
s :: 0:s → 0:s

Rewrite Strategy: INNERMOST

(5) CompletionProof (UPPER BOUND(ID) transformation)

The TRS is a completely defined constructor system, as every type has a constant constructor and the following rules were added:

cond(v0, v1) → null_cond [0]

And the following fresh constants:

null_cond

(6) Obligation:

Runtime Complexity Weighted TRS where all functions are completely defined. The underlying TRS is:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

cond(true, x) → cond(odd(x), p(x)) [1]
odd(0) → false [1]
odd(s(0)) → true [1]
odd(s(s(x))) → odd(x) [1]
p(0) → 0 [1]
p(s(x)) → x [1]
cond(v0, v1) → null_cond [0]

The TRS has the following type information:
cond :: true:false → 0:s → null_cond
true :: true:false
odd :: 0:s → true:false
p :: 0:s → 0:s
0 :: 0:s
false :: true:false
s :: 0:s → 0:s
null_cond :: null_cond

Rewrite Strategy: INNERMOST

(7) CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID) transformation)

Transformed the TRS into an over-approximating RNTS by (improved) Size Abstraction.
The constant constructors are abstracted as follows:

true => 1
0 => 0
false => 0
null_cond => 0

(8) Obligation:

Complexity RNTS consisting of the following rules:

cond(z, z') -{ 1 }→ cond(odd(x), p(x)) :|: z' = x, z = 1, x >= 0
cond(z, z') -{ 0 }→ 0 :|: v0 >= 0, v1 >= 0, z = v0, z' = v1
odd(z) -{ 1 }→ odd(x) :|: x >= 0, z = 1 + (1 + x)
odd(z) -{ 1 }→ 1 :|: z = 1 + 0
odd(z) -{ 1 }→ 0 :|: z = 0
p(z) -{ 1 }→ x :|: x >= 0, z = 1 + x
p(z) -{ 1 }→ 0 :|: z = 0

Only complete derivations are relevant for the runtime complexity.

(9) CompleteCoflocoProof (EQUIVALENT transformation)

Transformed the RNTS (where only complete derivations are relevant) into cost relations for CoFloCo:

eq(start(V, V1),0,[cond(V, V1, Out)],[V >= 0,V1 >= 0]).
eq(start(V, V1),0,[odd(V, Out)],[V >= 0]).
eq(start(V, V1),0,[p(V, Out)],[V >= 0]).
eq(cond(V, V1, Out),1,[odd(V2, Ret0),p(V2, Ret1),cond(Ret0, Ret1, Ret)],[Out = Ret,V1 = V2,V = 1,V2 >= 0]).
eq(odd(V, Out),1,[],[Out = 0,V = 0]).
eq(odd(V, Out),1,[],[Out = 1,V = 1]).
eq(odd(V, Out),1,[odd(V3, Ret2)],[Out = Ret2,V3 >= 0,V = 2 + V3]).
eq(p(V, Out),1,[],[Out = 0,V = 0]).
eq(p(V, Out),1,[],[Out = V4,V4 >= 0,V = 1 + V4]).
eq(cond(V, V1, Out),0,[],[Out = 0,V5 >= 0,V6 >= 0,V = V5,V1 = V6]).
input_output_vars(cond(V,V1,Out),[V,V1],[Out]).
input_output_vars(odd(V,Out),[V],[Out]).
input_output_vars(p(V,Out),[V],[Out]).

CoFloCo proof output:
Preprocessing Cost Relations
=====================================

#### Computed strongly connected components
0. recursive : [odd/2]
1. non_recursive : [p/2]
2. recursive : [cond/3]
3. non_recursive : [start/2]

#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into odd/2
1. SCC is partially evaluated into p/2
2. SCC is partially evaluated into cond/3
3. SCC is partially evaluated into start/2

Control-Flow Refinement of Cost Relations
=====================================

### Specialization of cost equations odd/2
* CE 9 is refined into CE [12]
* CE 8 is refined into CE [13]
* CE 7 is refined into CE [14]


### Cost equations --> "Loop" of odd/2
* CEs [13] --> Loop 9
* CEs [14] --> Loop 10
* CEs [12] --> Loop 11

### Ranking functions of CR odd(V,Out)
* RF of phase [11]: [V-1]

#### Partial ranking functions of CR odd(V,Out)
* Partial RF of phase [11]:
- RF of loop [11:1]:
V-1


### Specialization of cost equations p/2
* CE 11 is refined into CE [15]
* CE 10 is refined into CE [16]


### Cost equations --> "Loop" of p/2
* CEs [15] --> Loop 12
* CEs [16] --> Loop 13

### Ranking functions of CR p(V,Out)

#### Partial ranking functions of CR p(V,Out)


### Specialization of cost equations cond/3
* CE 6 is refined into CE [17]
* CE 5 is refined into CE [18,19,20,21]


### Cost equations --> "Loop" of cond/3
* CEs [21] --> Loop 14
* CEs [20] --> Loop 15
* CEs [19] --> Loop 16
* CEs [18] --> Loop 17
* CEs [17] --> Loop 18

### Ranking functions of CR cond(V,V1,Out)
* RF of phase [14]: [V1-2]

#### Partial ranking functions of CR cond(V,V1,Out)
* Partial RF of phase [14]:
- RF of loop [14:1]:
V1-2


### Specialization of cost equations start/2
* CE 2 is refined into CE [22,23,24]
* CE 3 is refined into CE [25,26,27,28]
* CE 4 is refined into CE [29,30]


### Cost equations --> "Loop" of start/2
* CEs [22] --> Loop 19
* CEs [23,24,26,27,28,30] --> Loop 20
* CEs [25,29] --> Loop 21

### Ranking functions of CR start(V,V1)

#### Partial ranking functions of CR start(V,V1)


Computing Bounds
=====================================

#### Cost of chains of odd(V,Out):
* Chain [[11],10]: 1*it(11)+1
Such that:it(11) =< V

with precondition: [Out=0,V>=2]

* Chain [[11],9]: 1*it(11)+1
Such that:it(11) =< V

with precondition: [Out=1,V>=3]

* Chain [10]: 1
with precondition: [V=0,Out=0]

* Chain [9]: 1
with precondition: [V=1,Out=1]


#### Cost of chains of p(V,Out):
* Chain [13]: 1
with precondition: [V=0,Out=0]

* Chain [12]: 1
with precondition: [V=Out+1,V>=1]


#### Cost of chains of cond(V,V1,Out):
* Chain [[14],18]: 3*it(14)+1*s(3)+0
Such that:aux(3) =< V1
it(14) =< aux(3)
s(3) =< it(14)*aux(3)

with precondition: [V=1,Out=0,V1>=3]

* Chain [[14],15,18]: 4*it(14)+1*s(3)+3
Such that:aux(4) =< V1
it(14) =< aux(4)
s(3) =< it(14)*aux(4)

with precondition: [V=1,Out=0,V1>=3]

* Chain [18]: 0
with precondition: [Out=0,V>=0,V1>=0]

* Chain [17,18]: 3
with precondition: [V=1,V1=0,Out=0]

* Chain [16,18]: 3
with precondition: [V=1,V1=1,Out=0]

* Chain [16,17,18]: 6
with precondition: [V=1,V1=1,Out=0]

* Chain [15,18]: 1*s(4)+3
Such that:s(4) =< V1

with precondition: [V=1,Out=0,V1>=2]


#### Cost of chains of start(V,V1):
* Chain [21]: 1
with precondition: [V=0]

* Chain [20]: 8*s(13)+2*s(14)+2*s(15)+6
Such that:s(12) =< V1
aux(6) =< V
s(15) =< aux(6)
s(13) =< s(12)
s(14) =< s(13)*s(12)

with precondition: [V>=1]

* Chain [19]: 3
with precondition: [V>=0,V1>=0]


Closed-form bounds of start(V,V1):
-------------------------------------
* Chain [21] with precondition: [V=0]
- Upper bound: 1
- Complexity: constant
* Chain [20] with precondition: [V>=1]
- Upper bound: 2*V+6+nat(V1)*8+nat(V1)*2*nat(V1)
- Complexity: n^2
* Chain [19] with precondition: [V>=0,V1>=0]
- Upper bound: 3
- Complexity: constant

### Maximum cost of start(V,V1): max([2,2*V+5+nat(V1)*8+nat(V1)*2*nat(V1)])+1
Asymptotic class: n^2
* Total analysis performed in 157 ms.

(10) BOUNDS(1, n^2)